package com.dianping.cat.home.graph.transform;

import com.dianping.cat.home.graph.entity.Graph;
import com.dianping.cat.home.graph.entity.Item;
import com.dianping.cat.home.graph.entity.Segment;
import org.xml.sax.Attributes;









public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public Graph buildGraph(Attributes attributes) {
/* 21 */     String id = attributes.getValue("id");
/* 22 */     return new Graph(id);
  }




  public Item buildItem(Attributes attributes) {
/* 29 */     String id = attributes.getValue("id");
/* 30 */     String view = attributes.getValue("view");
/* 31 */     Item item = new Item(id);

/* 33 */     if (view != null) {
/* 34 */       item.setView(view);
    }

/* 37 */     return item;
  }


  public Segment buildSegment(Attributes attributes) {
/* 42 */     String id = attributes.getValue("id");
/* 43 */     String category = attributes.getValue("category");
/* 44 */     String measure = attributes.getValue("measure");
/* 45 */     String endPoint = attributes.getValue("endPoint");
/* 46 */     String tags = attributes.getValue("tags");
/* 47 */     String type = attributes.getValue("type");
/* 48 */     Segment segment = new Segment(id);

/* 50 */     if (category != null) {
/* 51 */       segment.setCategory(category);
    }

/* 54 */     if (measure != null) {
/* 55 */       segment.setMeasure(measure);
    }

/* 58 */     if (endPoint != null) {
/* 59 */       segment.setEndPoint(endPoint);
    }

/* 62 */     if (tags != null) {
/* 63 */       segment.setTags(tags);
    }

/* 66 */     if (type != null) {
/* 67 */       segment.setType(type);
    }

/* 70 */     return segment;
  }


  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 75 */     if (value == null || value.length() == 0) {
/* 76 */       return defaultValue;
    }

/* 79 */     if (type == Boolean.class || type == boolean.class)
/* 80 */       return (T)Boolean.valueOf(value); 
/* 81 */     if (type == Integer.class || type == int.class)
/* 82 */       return (T)Integer.valueOf(value); 
/* 83 */     if (type == Long.class || type == long.class)
/* 84 */       return (T)Long.valueOf(value); 
/* 85 */     if (type == Short.class || type == short.class)
/* 86 */       return (T)Short.valueOf(value); 
/* 87 */     if (type == Float.class || type == float.class)
/* 88 */       return (T)Float.valueOf(value); 
/* 89 */     if (type == Double.class || type == double.class)
/* 90 */       return (T)Double.valueOf(value); 
/* 91 */     if (type == Byte.class || type == byte.class)
/* 92 */       return (T)Byte.valueOf(value); 
/* 93 */     if (type == Character.class || type == char.class) {
/* 94 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 96 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/graph/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */